home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Mac OS / MLTE SDK / MLTE_Hands-on / MLTESampleShell / MLTESampleShell.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-15  |  5.4 KB  |  164 lines  |  [TEXT/CWIE]

  1. /*
  2.     You may incorporate this sample code into your applications without
  3.     restriction, though the sample code has been provided "AS IS" and the
  4.     responsibility for its operation is 100% yours.  However, what you are
  5.     not permitted to do is to redistribute the source as "Apple Sample Code"
  6.     after having made changes. If you're going to re-distribute the source,
  7.     we require that you make it clear in the source that the code was
  8.     descended from Apple Sample Code, but that you've made changes.
  9.  
  10.     Copyright © 2000 Apple Computer, Inc., All Rights Reserved
  11. */
  12. #include <Devices.h>
  13. #include <DiskInit.h>
  14. #include <Gestalt.h>
  15. #include <MacTextEditor.h>
  16. #include <ToolUtils.h>
  17.  
  18. void main(void);
  19. void Initialize(void);
  20. void AlertUser(short error);
  21. void EventLoop(void);
  22. void DoEvent(EventRecord *event);
  23. void AdjustCursor(RgnHandle region);
  24. void DoGrowWindow(WindowPtr window, EventRecord *event);
  25. void DoZoomWindow(WindowPtr window, short part);
  26. void DoUpdate(WindowPtr window);
  27. void DoActivate(WindowPtr window, Boolean becomingActive);
  28. void DoContentClick( WindowPtr window, EventRecord *event);
  29. void DoKeyDown(EventRecord *event);
  30. static UInt32 GetSleep(void);
  31. void DoIdle(void);
  32. void AdjustMenus(void);
  33. void DoMenuCommand(long menuResult);
  34. void DoFontMenu(short menuID, short menuItem, WindowPtr window);
  35. void DoJustification(WindowPtr window, short menuItem);
  36. void DoWordWrap(WindowPtr window);
  37. void DoNew(void);
  38. Boolean DoCloseWindow( WindowPtr window);
  39. void Terminate(void);
  40. void BigBadError(short error);
  41. Boolean IsAppWindow(WindowPtr window);
  42. Boolean IsDAWindow(WindowPtr window);
  43. void InstallAppleEventHandlers(void);
  44. pascal OSErr HandleOapp (const AppleEvent *aevt, AEDescList *reply, UInt32 refCon);
  45. pascal OSErr HandleOdoc (const AppleEvent *aevt, AEDescList *reply, UInt32 refCon);
  46. pascal OSErr HandlePdoc (const AppleEvent *aevt, AEDescList *reply, UInt32 refCon);
  47. pascal OSErr HandleQuit (const AppleEvent *aevt, AEDescList *reply, UInt32 refCon);
  48. static void CheckSystemVersion(void);
  49.  
  50. // GInBackground is maintained by our OSEvent handling routines. Any part of
  51. // the program can check it to find out if it is currently in the background.
  52. Boolean    gInBackground;        // maintained by Initialize and DoEvent
  53.  
  54. // GNumDocuments is used to keep track of how many open documents there are
  55. // at any time. It is maintained by the routines that open and close documents.
  56. short    gNumDocuments;        // maintained by Initialize, DoNew, and DoCloseWindow
  57.  
  58. // Constants to identify menus and their items.
  59. #define    mApple                    128        // Apple menu
  60. #define    iAbout                    1
  61.  
  62. #define    mFile                    129        // File menu
  63. #define    iNew                    1
  64. #define    iClose                    4
  65. #define    iPageSetup                9
  66. #define    iPrint                    10
  67. #define    iQuit                    12
  68.  
  69. #define    mEdit                    130        // Edit menu
  70. #define    iUndo                    1
  71. #define    iRedo                    2
  72. #define    iCut                    4
  73. #define    iCopy                    5
  74. #define    iPaste                    6
  75. #define    iClear                    7
  76. #define    iSelectAll                9
  77.  
  78. #define    mFont                     131        // Font menu
  79.  
  80. #define    mSize                    132        // Size menu
  81. #define    i9Point                    1
  82. #define    i10Point                2
  83. #define    i12Point                3
  84. #define    i14Point                4
  85. #define    i18Point                5
  86. #define    i24Point                6
  87. #define    i36Point                7
  88. #define    iSmallerFontSize        9
  89. #define    iLargerFontSize            10
  90. #define    iOtherFontSize            12
  91.  
  92. #define    mStyle                    133        // Style menu
  93. #define    iPlain                    1
  94. #define    iBold                    2
  95. #define    iItalic                    3
  96. #define    iUnderline                4
  97. #define    iOutline                5
  98. #define    iShadow                    6
  99. #define    iCondensed                7
  100. #define    iExtended                8
  101.  
  102. #define    mLayout                    134        // Format menu
  103. #define    iDefaultJustify            1
  104. #define    iLeftJustify            2
  105. #define    iRightJustify            3
  106. #define    iCenterJustify            4
  107. #define    iFullJustify            5
  108. #define    iForceJustify            6
  109. #define    iAutoWrap                8
  110.  
  111. TXNFontMenuObject gTXNFontMenuObject;
  112.  
  113. const short    kStartHierMenuID = 160;
  114.  
  115. // For positioning disk initialization dialogs
  116. #define kDITop                    0x0050
  117. #define kDILeft                    0x0070
  118.  
  119. /* kMaxOpenDocuments is used to determine whether a new document can be opened
  120.    or created. We keep track of the number of open documents, and disable the
  121.    menu items that create a new document when the maximum is reached. If the
  122.    number of documents falls below the maximum, the items are enabled again. */
  123. #define    kMaxOpenDocuments        1
  124.         
  125. /* kOSEvent is the event number of the suspend/resume and mouse-moved events sent
  126.    by MultiFinder. Once we determine that an event is an OSEvent, we look at the
  127.    high byte of the message sent to determine which kind it is. To differentiate
  128.    suspend and resume events we check the resumeMask bit. */
  129. #define    kOSEvent                app4Evt    /* event used by MultiFinder */
  130. #define    kResumeMask                1        /* bit of message field for resume vs. suspend */
  131.  
  132. /* The following are indicies into STR# resources. */
  133. #define    eWrongSystem                1
  134. #define    eSmallSize                    2
  135. #define    eNoMemory                    3
  136. #define    eNoSpaceCut                    4
  137. #define    eNoCut                        5
  138. #define    eNoCopy                        6
  139. #define    eNoClear                    7
  140. #define    eExceedPaste                8
  141. #define    eNoSpacePaste                9
  142. #define    eNoWindow                    10
  143. #define    eExceedChar                    11
  144. #define    eNoPaste                    12
  145. #define    eNoMLTE                        13
  146. #define eNoAttachObjectToWindow     14
  147. #define eNoActivate                    15
  148. #define eObjectNotAttachedToWindow    16
  149. #define    eNoFontName                    17
  150. #define    eNoFontSize                    18
  151. #define    eNoFontStyle                19
  152. #define    eNoJustification            20
  153. #define eNoDisposeFontMenuObject    21
  154. #define    eNoWordWrap                    22
  155. #define eNoCreateFontMenuObject        23
  156.  
  157.  
  158. #define    rMenuBar    128                /* application's menu bar */
  159. #define    rAboutAlert    128                /* about alert */
  160. #define    rUserAlert    129                /* user error alert */
  161. #define    rDocWindow    128                /* application's window */
  162. #define    kErrStrings    128                /* error string list */
  163.  
  164.